﻿using System;
using System.Collections.Generic;
using System.Text;


namespace HAVNet.Intros.AST
{
    public class ASTMemberDeclProperty : ASTMemberDeclStruct
    {
        public bool             isPartial   { get; set; }
        public ASTType          type        { get; set; }
        public ASTMemberName    name        { get; set; }
        public readonly ASTAccessorNormals accesorDeclarations = new ASTAccessorNormals();

        public override string ToString ()
        {
            //  propEvntMethsMod    =
            //      newMod      |
            //      publicMod   |
            //      protectedMod|
            //      internalMod |
            //      privateMod  |
            //      unsafeMod   |
            //      staticMod   |
            //      virtualMod  |
            //      sealedMod   |
            //      overrideMod |
            //      abstractMod |
            //      externMod   ,

            string sAttrs = ((null == _attrGroups) ? "" : _attrGroups.ToString() + Environment.NewLine);

            string mods = "";

            if (Mods.has(modifiers, Mods.newMod         )) mods += "new ";
            if (Mods.has(modifiers, Mods.publicMod      )) mods += "public ";
            if (Mods.has(modifiers, Mods.protectedMod   )) mods += "protected ";
            if (Mods.has(modifiers, Mods.internalMod    )) mods += "internal ";
            if (Mods.has(modifiers, Mods.privateMod     )) mods += "private ";
            if (Mods.has(modifiers, Mods.unsafeMod      )) mods += "unsafe ";
            if (Mods.has(modifiers, Mods.staticMod      )) mods += "static ";
            if (Mods.has(modifiers, Mods.virtualMod     )) mods += "virtual ";
            if (Mods.has(modifiers, Mods.sealedMod      )) mods += "sealed ";
            if (Mods.has(modifiers, Mods.overrideMod    )) mods += "override ";
            if (Mods.has(modifiers, Mods.abstractMod    )) mods += "abstract ";
            if (Mods.has(modifiers, Mods.externMod      )) mods += "extern ";

            return
                sAttrs  +
                mods    +
                (isPartial ? " partial " : "") +
                type.ToString() + " " +
                name.ToString() + Environment.NewLine +
                "{" + Environment.NewLine + accesorDeclarations.ToString() + Environment.NewLine + "}" + Environment.NewLine + Environment.NewLine;
        }
    }
}
